<?php
class Album extends MY_Controller{
    function __construct() {
        parent::__construct();
        $this->load->model('model_albums');
        $this->load->helper('main_helper');
		$this->load->library("urlutility");
		$this->load->library("string");
    }
    function index() {
		$data['title'] = 'Photo albums';
        $data['template'] = "album/index";
		$data['vietnam'] = $this->destination(1);
		$data['cambodia'] = $this->destination(2);
		$data['hlaos'] = $this->destination(3);
		$data['blogvie'] = $this->model_home->blog(1);
		$data['blogcam'] = $this->model_home->blog(2);
		$data['bloglao'] = $this->model_home->blog(3);
		$data['holiday'] = $this->holiday();
		$data['destination'] = $this->model_home->destination();
        $destination = $this->model_albums->listdestina();
		$albums = array();
		foreach($destination as $k => $v){
			$albums[$v['destina_title']] = $this->model_albums->getalbums($v['destina_id']);
		}
		//$this->debug($albums);
		$data['listall'] = $albums;
        $this->load->view('album/layout',$data);
    }
	function detail(){
		$segment =  $this->uri->segment(2);
		$id = array_pop(explode('-',$segment));
		$data['vietnam'] = $this->destination(1);
		$data['cambodia'] = $this->destination(2);
		$data['hlaos'] = $this->destination(3);
		$data['blogvie'] = $this->model_home->blog(1);
		$data['blogcam'] = $this->model_home->blog(2);
		$data['bloglao'] = $this->model_home->blog(3);
		$data['holiday'] = $this->holiday();
        $data['template'] = "album/detail";
		$data['destination'] = $this->model_home->destination();
        $data['detail'] = $this->model_albums->getdata($id);
		if($data['detail'] == NULL){
			redirect(base_url());
		}
		$data['links']  = base_url().uri_string().".html";
		$data['related'] = $this->model_albums->related($data['detail']['destina_id'],$id);
		//$this->debug($data['related']);
		$data['title'] = $data["detail"]["title"]." - Photo albums";
		//$this->debug($data['listimage']);
        $this->load->view('album/layout2',$data);
	}
}
?>